package com.dragon.modules.yuegou.enums.product;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 发布类型
 * 
 * @author pbuilder generated
 *
 */
public enum HelpReleaseType {

	/**
	 * 商圈
	 */
	BUSD(0, "商圈"),
	/**
	 * 商户
	 */
	MERCHANT(1, "商户");

	/**
	 * 枚举标识
	 */
	private final Integer code;

	/**
	 * 别名
	 */
	private final String alias;

	private HelpReleaseType(Integer code, String alias) {
		this.code = code;
		this.alias = alias;
	}
	
	public Integer getValue() {
		return code;
	}

	/**
	 * 枚举标识
	 * 
	 * @return code
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * 别名
	 * 
	 * @return alias
	 */
	public String getAlias() {
		return alias;
	}

	/**
	 * 把code转化为费用类型枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	@JsonCreator
	public static HelpReleaseType from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for HelpReleaseType
	 */
	private static final Map<Integer, HelpReleaseType> CODE_MAP = Stream.of(HelpReleaseType.values())
			.collect(Collectors.toMap(HelpReleaseType::getCode, e -> e));

}
